package com.zy.sample;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

import com.zy.http.GetURLContent;

public class GetURLContentSample {
	public static void main(String[] args) throws IOException {
		String url = "http://hk.weather.yahoo.com/#forecast-tab";
		String proxy = "http://192.168.22.81";
		int port = 80;
		String username = "username";
		String password = "password";
		String curLine = "";
		String content = "";
		URL server = new URL(url);
		GetURLContent.initProxy(proxy, port, username, password);
		HttpURLConnection connection = (HttpURLConnection) server
				.openConnection();
		connection.connect();
		InputStream is = connection.getInputStream();
		BufferedReader reader = new BufferedReader(new
		InputStreamReader(is));
		while ((curLine = reader.readLine()) != null) {
			content = content + curLine + "\r\n";
		}
		System.out.println("content= " + content);
		is.close();
		System.out.println(GetURLContent.getContent(url));
	}
}
